﻿<UserControl x:Class="IssueVision.Client.AllIssues"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="4*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <data:DataGrid Grid.Row="0" Grid.Column="0"
                       AutoGenerateColumns="False"
                       ItemsSource="{Binding Path=AllIssuesSource.View}"
                       SelectedItem="{Binding Path=CurrentIssue, Mode=OneWay}"
                       SelectionMode="Single" IsReadOnly="True">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand PassEventArgsToCommand="True"
                                        Command="{Binding Path=SelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Header="ID" Binding="{Binding Path=IssueID, ValidatesOnNotifyDataErrors=False}" Width="35" />
                <data:DataGridTextColumn Header="Title" Binding="{Binding Path=Title, ValidatesOnNotifyDataErrors=False}" Width="6*" />
                <data:DataGridTextColumn Header="Status" Binding="{Binding Path=Status.Name, ValidatesOnNotifyDataErrors=False}" Width="*" />
                <data:DataGridTextColumn Header="Pri" Binding="{Binding Path=Priority, ValidatesOnNotifyDataErrors=False}" Width="35" />
                <data:DataGridTextColumn Header="Assigned To" Binding="{Binding Path=AssignedToID, TargetNullValue=Open, ValidatesOnNotifyDataErrors=False}" Width="70" />
            </data:DataGrid.Columns>
        </data:DataGrid>
        <controls:GridSplitter Grid.Row="1" Grid.Column="0"
                               Height="14" HorizontalAlignment="Stretch"/>
        <ContentControl x:Name="issueEditorContentControl" Grid.Row="2"
                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
        <Button Grid.Row="3" Grid.Column="0"
                VerticalAlignment="Top" HorizontalAlignment="Right" 
                Width="75" Height="23" Margin="0,5,167,5" 
                Content="Refresh"
                Command="{Binding Path=RefreshCommand}"/>
        <Button Grid.Row="3" Grid.Column="0"
                VerticalAlignment="Top" HorizontalAlignment="Right" 
                Width="75" Height="23" Margin="0,5,86,5" 
                Content="Save"
                Command="{Binding Path=SubmitChangeCommand}"/>
        <Button  Grid.Row="3" Grid.Column="0"
                 VerticalAlignment="Top" HorizontalAlignment="Right"
                 Width="75" Height="23" Margin="0,5,5,5"
                 Content="Cancel"
                Command="{Binding Path=CancelChangeCommand}"/>
    </Grid>
</UserControl>
